# encoding: utf-8

import logging

# 异常
try:
    print 'try'
    r = 10/0
    print "result is",r
except ZeroDivisionError,e:
    print "exception",e.message,e.args
finally:
    print "finally"

print( "end" )

# 多异常
def try_mulitilp_exc(divisor):
    try:
        print("try")
        r = 10/ int(divisor)
        print r
    except ValueError,e:
        print e.message
    except Exception,e:
        print e.message

try_mulitilp_exc(0)
try_mulitilp_exc("a")

# 使用logging模块处理异常

try:
    10/0
except BaseException,e:
    logging.exception(e)
    #raise  # raise 用以抛出异常
print("continue")

# 程序调试技术
#1 print
#2 asset
def devision(a,b):
    assert b != 0,"b is zero"
    return a/b

print devision(1,1)

logging.basicConfig(level=logging.INFO) # 降低程序日志记录等级
logging.info("run here")

